package com.veer.shop.pojo;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.veer.shop.config.ResponseCodeEnum;

/**
 * 统一业务返回格式
 * 
 * @author WangBin
 * 2020年8月12日-下午3:16:55
 */
public class ResponseData<T> implements Serializable{

	private static final long serialVersionUID = 1L;

	// 错误码
	private int code;
	
	// 提示信息
	private String msg;
	
	// 返回数据
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private T data;
	
	public ResponseData(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
	
	public ResponseData(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
	
	public ResponseData(ResponseCodeEnum responseCodeEnum) {
        this.code = responseCodeEnum.getCode();
        this.msg = responseCodeEnum.getMessage();
    }
	
	public ResponseData(ResponseCodeEnum responseCodeEnum, String msg) {
        this.code = responseCodeEnum.getCode();
        this.msg = msg;
    }
	
	public ResponseData(ResponseCodeEnum resultEnums, T data) {
        this.code = resultEnums.getCode();
        this.msg = resultEnums.getMessage();
        this.data = data;
    }
	
	public ResponseData() {}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return msg;
	}

	public void setMessage(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}
}
